package com.ruoyi.zhmk.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.zhmk.domain.ZhmkUsersend;
import com.ruoyi.zhmk.service.IZhmkUsersendService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 人员下发Controller
 * 
 * @author sxl
 * @date 2021-06-10
 */
@Controller
@RequestMapping("/zhmk/usersend")
public class ZhmkUsersendController extends BaseController
{
    private String prefix = "zhmk/usersend";

    @Autowired
    private IZhmkUsersendService zhmkUsersendService;

    @RequiresPermissions("zhmk:usersend:view")
    @GetMapping()
    public String usersend()
    {
        return prefix + "/usersend";
    }

    /**
     * 查询人员下发列表
     */
    @RequiresPermissions("zhmk:usersend:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(ZhmkUsersend zhmkUsersend)
    {
        startPage();
        List<ZhmkUsersend> list = zhmkUsersendService.selectZhmkUsersendList(zhmkUsersend);
        return getDataTable(list);
    }

    /**
     * 导出人员下发列表
     */
    @RequiresPermissions("zhmk:usersend:export")
    @Log(title = "人员下发", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(ZhmkUsersend zhmkUsersend)
    {
        List<ZhmkUsersend> list = zhmkUsersendService.selectZhmkUsersendList(zhmkUsersend);
        ExcelUtil<ZhmkUsersend> util = new ExcelUtil<ZhmkUsersend>(ZhmkUsersend.class);
        return util.exportExcel(list, "人员下发数据");
    }

    /**
     * 新增人员下发
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存人员下发
     */
    @RequiresPermissions("zhmk:usersend:add")
    @Log(title = "人员下发", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(ZhmkUsersend zhmkUsersend)
    {
        return toAjax(zhmkUsersendService.insertZhmkUsersend(zhmkUsersend));
    }

    /**
     * 修改人员下发
     */
    @GetMapping("/edit/{usersendId}")
    public String edit(@PathVariable("usersendId") Long usersendId, ModelMap mmap)
    {
        ZhmkUsersend zhmkUsersend = zhmkUsersendService.selectZhmkUsersendById(usersendId);
        mmap.put("zhmkUsersend", zhmkUsersend);
        return prefix + "/edit";
    }

    /**
     * 修改保存人员下发
     */
    @RequiresPermissions("zhmk:usersend:edit")
    @Log(title = "人员下发", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(ZhmkUsersend zhmkUsersend)
    {
        return toAjax(zhmkUsersendService.updateZhmkUsersend(zhmkUsersend));
    }

    /**
     * 删除人员下发
     */
    @RequiresPermissions("zhmk:usersend:remove")
    @Log(title = "人员下发", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(zhmkUsersendService.deleteZhmkUsersendByIds(ids));
    }
}
